<template>
    <el-empty description="您还未登录" v-if="token == null"></el-empty>
    <div v-else>
        <el-table :data="tableData" stripe style="width: 100%">
            <el-table-column type="index" width="80" label="序号" />
            <el-table-column prop="stu.name" label="学员姓名" width="180" />
            <el-table-column prop="coa.coach_name" label="所属教练" width="180" />
            <el-table-column prop="car.car_pai" label="训练车辆" width="180" />
            <el-table-column prop="test.subject_name" label="训练科目" width="180" />
            <el-table-column prop="ground" label="训练场地" width="180" />
            <el-table-column prop="train_time" label="训练时间" width="180">
                <template #default="{ row }">
                    <el-tooltip :content=row.train_time effect="dark">
                        <el-tag size="small">{{ row.train_time }}</el-tag>
                    </el-tooltip>
                </template>

            </el-table-column>
            <el-table-column prop="comment_student" label="我的评论" />
        </el-table>
        <el-pagination v-model:current-page="currentPage4" v-model:page-size="pageSize4" :page-sizes="[5, 10, 15, 20]"
            :size="size" :disabled="disabled" :background="background" layout="total, sizes, prev, pager, next, jumper"
            :total=total @size-change="handleSizeChange" @current-change="handleCurrentChange"
            class="pagination-container" />
    </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import axios from 'axios';
const token = localStorage.getItem('token')
const tableData = ref([])
// 分页值
const pageSize4 = ref(5)
const currentPage4 = ref(1)
const total = ref(10)
function getdata() {
    axios.get("http://127.0.0.1:8000/driver_school/select_student_teach/", {
        headers: {
            token: token
        },
        params: {
            page: currentPage4.value,
            pagesize: pageSize4.value,
        }
    })
        .then(res => {
            console.log(res)
            tableData.value = res.data.data
            total.value = res.data.total
        })
        .catch(err => {
            console.error(err);
        })
}
// 分页
function handleSizeChange(size) {
    pageSize4.value = size
    getdata()
}
// 分页
function handleCurrentChange(page) {
    currentPage4.value = page
    getdata()
}
onMounted(() => {
    // Your code here
    getdata()
});

// 在组件卸载前执行的操作
onUnmounted(() => {
    // Your code here
});
</script>